<template>
  <view class="error-page">
    <view class="error-container">
      <!-- 404立体数字 -->
      <view class="error-graphic">
        <view class="number-404">
          <text class="number-4 first">4</text>
          <text class="number-0">0</text>
          <text class="number-4 last">4</text>
        </view>
        <!-- 装饰元素 -->
        <view class="decoration-elements">
          <view class="triangle triangle-1"></view>
          <view class="triangle triangle-2"></view>
          <view class="circle circle-1"></view>
          <view class="circle circle-2"></view>
        </view>
      </view>

      <!-- 右侧文字内容 -->
      <view class="error-content">
        <!-- <view class="error-title">404错误!</view> -->
        <view class="error-subtitle">找不到网页!</view>
        <view class="error-desc">
          抱歉，您访问的页面不存在，
          请返回首页继续浏览！
        </view>
        <button @click="goHome" class="btn-home">返回首页</button>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  methods: {
    goBack() {
      uni.navigateBack({
        delta: 1,
        fail: () => {
          // 如果无法返回，则跳转到首页
          this.goHome()
        }
      })
    },
    goHome() {
      uni.reLaunch({
        url: '/pages/index'
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.error-page {
  width: 100%;
  height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40rpx;
  box-sizing: border-box;
}

.error-container {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 1000rpx;
  width: 100%;
  gap: 80rpx;
}

// 左侧404图形
.error-graphic {
  position: relative;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 400rpx;
}

.number-404 {
  display: flex;
  align-items: center;
  position: relative;
  z-index: 2;
}

.number-4,
.number-0 {
  font-size: 200rpx;
  font-weight: 800;
  line-height: 1;
  position: relative;
}

.number-4 {
  color: #0081ff;
  text-shadow:
    0 10rpx 20rpx rgba(0, 129, 255, 0.3),
    0 20rpx 40rpx rgba(0, 129, 255, 0.2);

  &.first {
    transform: perspective(400rpx) rotateY(-15deg);
  }

  &.last {
    transform: perspective(400rpx) rotateY(15deg);
  }
}

.number-0 {
  color: #4da6ff;
  margin: 0 -20rpx;
  transform: perspective(400rpx) rotateX(10deg);
  text-shadow:
    0 10rpx 20rpx rgba(77, 166, 255, 0.3),
    0 20rpx 40rpx rgba(77, 166, 255, 0.2);
}

// 装饰元素
.decoration-elements {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

.triangle {
  position: absolute;
  width: 0;
  height: 0;

  &.triangle-1 {
    top: 50rpx;
    left: 100rpx;
    border-left: 30rpx solid transparent;
    border-right: 30rpx solid transparent;
    border-bottom: 50rpx solid #FFB74D;
    transform: rotate(15deg);
    animation: float 3s ease-in-out infinite;
  }

  &.triangle-2 {
    bottom: 80rpx;
    right: 120rpx;
    border-left: 20rpx solid transparent;
    border-right: 20rpx solid transparent;
    border-bottom: 35rpx solid #FF8A65;
    transform: rotate(-25deg);
    animation: float 3s ease-in-out infinite 1.5s;
  }
}

.circle {
  position: absolute;
  border-radius: 50%;

  &.circle-1 {
    top: 120rpx;
    right: 80rpx;
    width: 40rpx;
    height: 40rpx;
    background: #81C784;
    animation: bounce 2s ease-in-out infinite;
  }

  &.circle-2 {
    bottom: 150rpx;
    left: 60rpx;
    width: 25rpx;
    height: 25rpx;
    background: #E57373;
    animation: bounce 2s ease-in-out infinite 1s;
  }
}

// 右侧内容
.error-content {
  flex: 1;
  text-align: left;
  max-width: 400rpx;
}

.error-title {
  font-size: 48rpx;
  font-weight: 700;
  color: #0081ff;
  margin-bottom: 16rpx;
  letter-spacing: 1rpx;
}

.error-subtitle {
  font-size: 36rpx;
  font-weight: 600;
  color: #333;
  margin-bottom: 32rpx;
}

.error-desc {
  font-size: 28rpx;
  color: #666;
  line-height: 1.6;
  margin-bottom: 58rpx;
  letter-spacing: 0.5rpx;
}

.btn-home {
  background: linear-gradient(135deg, #3c9cff 0%, #2b7ce6 100%);
  color: white;
  border: none;
  padding: 0 36rpx;
  border-radius: 50rpx;
  font-size: 30rpx;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow:
    0 8rpx 24rpx rgba(60, 156, 255, 0.3),
    0 4rpx 8rpx rgba(60, 156, 255, 0.2),
    inset 0 1rpx 0 rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
  letter-spacing: 1rpx;
  min-width: 240rpx;

  // 光泽效果
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent);
    transition: left 0.6s ease;
  }

  // 内部光晕
  &::after {
    content: '';
    position: absolute;
    top: 2rpx;
    left: 2rpx;
    right: 2rpx;
    bottom: 2rpx;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, transparent 50%);
    border-radius: 48rpx;
    pointer-events: none;
  }

  &:hover {
    background: linear-gradient(135deg, #2b7ce6 0%, #1a6bd1 100%);
    transform: translateY(-4rpx) scale(1.02);
    box-shadow:
      0 16rpx 32rpx rgba(60, 156, 255, 0.4),
      0 8rpx 16rpx rgba(60, 156, 255, 0.3),
      inset 0 1rpx 0 rgba(255, 255, 255, 0.3);

    &::before {
      left: 100%;
    }
  }

  &:active {
    transform: translateY(-2rpx) scale(1.01);
    transition: all 0.1s ease;
    box-shadow:
      0 8rpx 16rpx rgba(60, 156, 255, 0.3),
      0 4rpx 8rpx rgba(60, 156, 255, 0.2),
      inset 0 1rpx 0 rgba(255, 255, 255, 0.2);
  }
}

// 动画
@keyframes float {

  0%,
  100% {
    transform: translateY(0) rotate(15deg);
  }

  50% {
    transform: translateY(-20rpx) rotate(15deg);
  }
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-15rpx);
  }
}

// 响应式设计
@media (max-width: 750rpx) {
  .error-container {
    flex-direction: column;
    gap: 60rpx;
    text-align: center;
  }

  .error-graphic {
    min-height: 300rpx;
  }

  .number-4,
  .number-0 {
    font-size: 150rpx;
  }

  .error-content {
    text-align: center;
    max-width: 100%;
  }

  .error-title {
    font-size: 40rpx;
  }

  .error-subtitle {
    font-size: 32rpx;
  }

  .error-desc {
    font-size: 26rpx;
  }

  .btn-home {
    width: 100%;
    max-width: 300rpx;
  }

  .triangle {
    &.triangle-1 {
      top: 30rpx;
      left: 50rpx;
    }

    &.triangle-2 {
      bottom: 40rpx;
      right: 60rpx;
    }
  }

  .circle {
    &.circle-1 {
      top: 80rpx;
      right: 40rpx;
    }

    &.circle-2 {
      bottom: 100rpx;
      left: 30rpx;
    }
  }
}
</style>